package cn.edu.scujcc;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class CommodityController {
	@Autowired
private CommodityService service;
	@PostMapping("/Comment")
	public Commodity createCommodity (@RequestBody Commodity c) {
		Commodity result = null;
		result = service.createCommodity(c);
		return result;
	}
	@GetMapping("/Comment/{id}")
	public List<Commodity> getAllCommodity(){
		List<Commodity> result = null;
		result = service.getAllCommodity();
		return result;
	}
	
	@GetMapping("/Comment/{id}")
	public Commodity getChannel(@PathVariable User id) {
		Commodity result= null;
		result = service.getCommodity(id);
		return result;
	}
	@DeleteMapping("/{id}")
	public boolean delete(@PathVariable User id) {
		boolean result= false;
		result = service.deleteCommodity(id);
		return result;
	}
}

